package com.wg.model;

import org.hibernate.annotations.GenericGenerator;
import xyz.erupt.annotation.Erupt;
import xyz.erupt.annotation.EruptField;
import xyz.erupt.annotation.sub_erupt.Power;
import xyz.erupt.annotation.sub_field.Edit;
import xyz.erupt.annotation.sub_field.EditType;
import xyz.erupt.annotation.sub_field.View;
import xyz.erupt.annotation.sub_field.sub_edit.ChoiceType;
import xyz.erupt.jpa.model.BaseModel;
import xyz.erupt.toolkit.handler.SqlChoiceFetchHandler;

import javax.persistence.*;

@Erupt(name = "wgUsers", power = @Power(
                importable = true, export = true
))
@Table(name = "tb_users")
@Entity
public class UserModel extends BaseModel {

    //文本输入
    @EruptField(
            views = @View(title = "用户名"),
            edit = @Edit(title = "用户名")
    )
    private String name;

    @EruptField(
            views = @View(title = "工号"),
            edit = @Edit(title = "工号")
    )
    private String jobNo;

    @EruptField(
            views = @View(title = "邮箱"),
            edit = @Edit(title = "邮箱")
    )
    private String email;

    @EruptField(
            views = @View(title = "个性签名"),
            edit = @Edit(title = "个性签名", type = EditType.TEXTAREA)
    )
    private String brief;

    @EruptField(
            views = @View(title = "部门"),
            edit = @Edit(
                    title = "部门",
                    type = EditType.CHOICE,
                    choiceType = @ChoiceType(
                            fetchHandler = SqlChoiceFetchHandler.class,
                            fetchHandlerParams = {"select id, name from tb_depts", "5000"}
                    )
            )
    )
    private Long deptId;

    @EruptField(
            views = @View(title = "职位"),
            edit = @Edit(
                    title = "职位",
                    type = EditType.CHOICE,
                    choiceType = @ChoiceType(
                            fetchHandler = SqlChoiceFetchHandler.class,
                            fetchHandlerParams = {"select id, name from tb_jobs", "5000"}
                    )
            )
    )
    private Long jobId;


}
